package com.huawei.appgallery.festivalanimation.particle;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Interpolator;
import com.huawei.hms.framework.network.restclient.hwhttp.route.IPRoute;
import com.huawei.hwphy2d.physical.util.BarrierParameters;
import com.huawei.hwphy2d.physical.util.DeviceParameters;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor.AbortPolicy;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import o.bqq;
import o.iu;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ParticleManager {
    private static final String ACCELERATION = "Acceleration";
    private static final String ACCELERATION_ACCELERATION = "acceleration";
    private static final String ACCELERATION_MAXANGLE = "maxAngle";
    private static final String ACCELERATION_MINANGLE = "minAngle";
    private static final String ALPHARANGE = "AlphaRange";
    private static final String ALPHARANGE_MAXALPHA = "maxAlpha";
    private static final String ALPHARANGE_MINALPHA = "minAlpha";
    private static final double AREA_LEFT = 0.15d;
    private static final double AREA_RIGHT = 0.85d;
    private static final int FIRE_FLOWER = 2;
    private static final String OPACITYOVERLIFE = "OpacityOverLife";
    private static final String OPACITYOVERLIFE_ENDMILIS = "endMilis";
    private static final String OPACITYOVERLIFE_FROMVALUE = "fromValue";
    private static final String OPACITYOVERLIFE_STARTMILIS = "startMilis";
    private static final String OPACITYOVERLIFE_TOVALUE = "toValue";
    private static final String PARAM_BITMAPNAME = "bitmapName";
    private static final String PARAM_BITMAPS = "bitmaps";
    private static final String PARAM_FPS = "fps";
    private static final String PARAM_MAXPATICLES = "maxParticles";
    private static final String PARAM_PARTICLESPERSECOND = "particlesPerSecond";
    private static final String PARAM_TIMETOLIVE = "timeToLive";
    private static final String ROTATION = "Rotation";
    private static final String ROTATION_MAXANGLE = "maxAngle";
    private static final String ROTATION_MINANGLE = "minAngle";
    private static final String ROTATION_SPEED = "rotationSpeed";
    private static final String SCALERANGE = "ScaleRange";
    private static final String SCALERANGE_MAXSCALE = "maxScale";
    private static final String SCALERANGE_MINSCALE = "minScale";
    private static final String SIZEOVERLIFE = "SizeOverLife";
    private static final String SPEEDRANGE = "SpeedRange";
    private static final String SPEEDRANGE_MAXANGLE = "maxAngle";
    private static final String SPEEDRANGE_MINANGLE = "minAngle";
    private static final String SPEEDRANGE_SPEEDMAX = "speedMax";
    private static final String SPEEDRANGE_SPEEDMIN = "speedMin";
    private static final String TAG = "ParticleManager";
    private static ExecutorService singleThreadPool;
    private ArrayList<Acceleration> al = new ArrayList();
    private ArrayList<AlphaRange> alphal = new ArrayList();
    private String jsonFilePath;
    private ParticleSystem mFireWorkPSOne = null;
    private ParticleSystem mFireWorkPSThree = null;
    private ParticleSystem mFireWorkPSTwo = null;
    private ParticleSystem mParticleSystem = null;
    private ViewGroup mViewGroup;
    private ArrayList<OpacityOverLife> opacityl = new ArrayList();
    private Param param = new Param();
    private Rotation rotation = new Rotation();
    private ArrayList<ScaleRange> scalel = new ArrayList();
    private ArrayList<SizeOverLife> sizel = new ArrayList();
    private ArrayList<SpeedRange> speedl = new ArrayList();

    static class Acceleration {
        private float acceleration;
        private int maxAngle;
        private int minAngle;

        private Acceleration() {
        }
    }

    static class AlphaRange {
        private int maxAlpha;
        private int minAlpha;

        private AlphaRange() {
        }
    }

    static class CustomThreadFactoryBuilder {
        private boolean daemon;
        private String namePrefix;
        private int priority;

        private CustomThreadFactoryBuilder() {
            this.namePrefix = null;
            this.daemon = false;
            this.priority = 5;
        }

        public CustomThreadFactoryBuilder setNamePrefix(String str) {
            if (str == null) {
                throw new NullPointerException();
            }
            this.namePrefix = str;
            return this;
        }

        public CustomThreadFactoryBuilder setDaemon(boolean z) {
            this.daemon = z;
            return this;
        }

        public CustomThreadFactoryBuilder setPriority(int i) {
            if (i < 1) {
                throw new IllegalArgumentException(String.format("Thread priority (%s) must be >= %s", new Object[]{Integer.valueOf(i), Integer.valueOf(1)}));
            } else if (i > 10) {
                throw new IllegalArgumentException(String.format("Thread priority (%s) must be <= %s", new Object[]{Integer.valueOf(i), Integer.valueOf(10)}));
            } else {
                this.priority = i;
                return this;
            }
        }

        public ThreadFactory build() {
            return build(this);
        }

        private ThreadFactory build(CustomThreadFactoryBuilder customThreadFactoryBuilder) {
            final String str = customThreadFactoryBuilder.namePrefix;
            final Boolean valueOf = Boolean.valueOf(customThreadFactoryBuilder.daemon);
            final Integer valueOf2 = Integer.valueOf(customThreadFactoryBuilder.priority);
            final AtomicLong atomicLong = new AtomicLong(0);
            return new ThreadFactory() {
                public Thread newThread(Runnable runnable) {
                    Thread thread = new Thread(runnable);
                    if (str != null) {
                        thread.setName(str + "-" + atomicLong.getAndIncrement());
                    }
                    if (valueOf != null) {
                        thread.setDaemon(valueOf.booleanValue());
                    }
                    if (valueOf2 != null) {
                        thread.setPriority(valueOf2.intValue());
                    }
                    return thread;
                }
            };
        }
    }

    static class OpacityOverLife {
        private long endMilis;
        private int fromValue;
        private long startMilis;
        private int toValue;

        private OpacityOverLife() {
        }
    }

    static class Param {
        private int fps;
        private int maxParticles;
        private Drawable[] particle;
        private int particlesPerSecond;
        private Path path;
        private Rect rect;
        private long timeToLive;

        private Param() {
        }
    }

    static class Rotation {
        private int maxAngle;
        private int minAngle;
        private float rotationSpeed;

        private Rotation() {
        }
    }

    static class ScaleRange {
        private float maxScale;
        private float minScale;

        private ScaleRange() {
        }
    }

    static class SizeOverLife {
        private long endMilis;
        private int fromValue;
        private long startMilis;
        private int toValue;

        private SizeOverLife() {
        }
    }

    static class SpeedRange {
        private int maxAngle;
        private int minAngle;
        private float speedMax;
        private float speedMin;

        private SpeedRange() {
        }
    }

    static {
        int i = 1;
        singleThreadPool = new ThreadPoolExecutor(1, i, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(WXMediaMessage.DESCRIPTION_LENGTH_LIMIT), new CustomThreadFactoryBuilder().setNamePrefix("ParticleManager-pool").setDaemon(false).build(), new AbortPolicy());
    }

    public ParticleManager(String str) {
        this.jsonFilePath = str;
    }

    public void startParticleEffect(ViewGroup viewGroup, final int i) {
        this.mViewGroup = viewGroup;
        final Handler handler = new Handler(Looper.getMainLooper());
        singleThreadPool.execute(new Runnable() {
            public void run() {
                bqq.ॱ.ˋ(ParticleManager.TAG, "Particle animation is running on " + Thread.currentThread().getName() + " with priority " + Thread.currentThread().getPriority());
                if (2 != i) {
                    ParticleManager.this.readParamsFronJson();
                    handler.post(new Runnable() {
                        public void run() {
                            ParticleManager.this.startEmit();
                        }
                    });
                    return;
                }
                handler.post(new Runnable() {
                    public void run() {
                        ParticleManager.this.startEmitFireWork();
                    }
                });
            }
        });
    }

    private void startEmit() {
        bqq.ॱ.ˋ(TAG, "startEmit");
        Path access$600 = this.param.path;
        if (this.mParticleSystem != null) {
            this.mParticleSystem.cancel();
        }
        configBeforeStart();
        ParticleSystem.setFPS((double) this.param.fps);
        if (this.mParticleSystem == null) {
            return;
        }
        if (this.param.rect != null) {
            this.mParticleSystem.emit(this.param.rect, this.param.particlesPerSecond);
        } else if (this.param.path != null) {
            this.mParticleSystem.emit(access$600, this.param.particlesPerSecond);
        }
    }

    private void configBeforeStart() {
        int i;
        int i2 = 0;
        Interpolator ˋ = iu.ˋ(BarrierParameters.RESTITUTION, 0.55f, 0.35f, 1.0f);
        Interpolator ˋ2 = iu.ˋ(0.5f, 0.96f, 0.77f, 1.0f);
        this.mParticleSystem = new ParticleSystem(this.mViewGroup, this.param.maxParticles, this.param.timeToLive, Boolean.valueOf(false), this.param.particle);
        this.mParticleSystem.setRotationSpeed(this.rotation.rotationSpeed);
        this.mParticleSystem.setRotationSpeedRange((float) this.rotation.minAngle, (float) this.rotation.maxAngle);
        for (i = 0; i < this.al.size(); i++) {
            Acceleration acceleration = (Acceleration) this.al.get(i);
            this.mParticleSystem.setAcceleration(acceleration.acceleration, acceleration.minAngle, acceleration.maxAngle);
        }
        for (i = 0; i < this.speedl.size(); i++) {
            SpeedRange speedRange = (SpeedRange) this.speedl.get(i);
            this.mParticleSystem.setSpeedRange(speedRange.speedMin, speedRange.speedMax, speedRange.minAngle, speedRange.maxAngle);
        }
        for (i = 0; i < this.scalel.size(); i++) {
            ScaleRange scaleRange = (ScaleRange) this.scalel.get(i);
            this.mParticleSystem.setScaleRange(scaleRange.minScale, scaleRange.maxScale);
        }
        for (i = 0; i < this.alphal.size(); i++) {
            AlphaRange alphaRange = (AlphaRange) this.alphal.get(i);
            this.mParticleSystem.setAlphaRange(alphaRange.minAlpha, alphaRange.maxAlpha);
        }
        for (int i3 = 0; i3 < this.opacityl.size(); i3++) {
            OpacityOverLife opacityOverLife = (OpacityOverLife) this.opacityl.get(i3);
            this.mParticleSystem.setOpacityOverLife(opacityOverLife.fromValue, opacityOverLife.toValue, opacityOverLife.startMilis, opacityOverLife.endMilis, ˋ);
        }
        while (i2 < this.sizel.size()) {
            SizeOverLife sizeOverLife = (SizeOverLife) this.sizel.get(i2);
            this.mParticleSystem.setOpacityOverLife(sizeOverLife.fromValue, sizeOverLife.toValue, sizeOverLife.startMilis, sizeOverLife.endMilis, ˋ2);
            i2++;
        }
    }

    private double getRandom() {
        double random = Math.random();
        if (random < AREA_LEFT) {
            return random + AREA_LEFT;
        }
        if (random > AREA_RIGHT) {
            return random - AREA_LEFT;
        }
        return random;
    }

    private void startEmitFireWork() {
        this.mFireWorkPSOne = new ParticleSystem(this.mViewGroup, 100, Drawable.createFromPath(this.jsonFilePath + "fire1.png"), 800, false);
        this.mFireWorkPSOne.setScaleRange(0.03f, 0.06f);
        this.mFireWorkPSOne.setSpeedRange(BarrierParameters.RESTITUTION, 0.25f);
        this.mFireWorkPSOne.setFadeOut(200, new AccelerateInterpolator());
        Point point = new Point();
        point.x = (int) (((double) DeviceParameters.getScreenWidth(this.mViewGroup.getContext())) * getRandom());
        point.y = (int) ((((double) DeviceParameters.getScreenHeight(this.mViewGroup.getContext())) * getRandom()) * 0.4d);
        this.mFireWorkPSOne.oneShot(point, 70, 33);
        this.mFireWorkPSTwo = new ParticleSystem(this.mViewGroup, 50, Drawable.createFromPath(this.jsonFilePath + "fire2.png"), 800, false);
        this.mFireWorkPSTwo.setScaleRange(0.3f, 0.6f);
        this.mFireWorkPSTwo.setSpeedRange(0.02f, 0.15f);
        this.mFireWorkPSTwo.setFadeOut(200, new AccelerateInterpolator());
        point = new Point();
        point.x = (int) (((double) DeviceParameters.getScreenWidth(this.mViewGroup.getContext())) * getRandom());
        point.y = (int) ((((double) DeviceParameters.getScreenHeight(this.mViewGroup.getContext())) * getRandom()) * 0.4d);
        this.mFireWorkPSTwo.oneShot(point, 30, 833);
        this.mFireWorkPSThree = new ParticleSystem(this.mViewGroup, 50, Drawable.createFromPath(this.jsonFilePath + "fire2.png"), 800, false);
        this.mFireWorkPSThree.setScaleRange(0.3f, 0.8f);
        this.mFireWorkPSThree.setSpeedRange(0.02f, 0.15f);
        this.mFireWorkPSThree.setFadeOut(200, new AccelerateInterpolator());
        point = new Point();
        point.x = (int) (((double) DeviceParameters.getScreenWidth(this.mViewGroup.getContext())) * getRandom());
        point.y = (int) ((((double) DeviceParameters.getScreenHeight(this.mViewGroup.getContext())) * getRandom()) * 0.4d);
        this.mFireWorkPSThree.oneShot(point, 40, IPRoute.INTERVAL);
    }

    public void stopParticleEffect() {
        if (this.mParticleSystem != null) {
            this.mParticleSystem.cancel();
        }
        if (this.mFireWorkPSOne != null) {
            this.mFireWorkPSOne.cancel();
        }
        if (this.mFireWorkPSTwo != null) {
            this.mFireWorkPSTwo.cancel();
        }
        if (this.mFireWorkPSThree != null) {
            this.mFireWorkPSThree.cancel();
        }
    }

    @SuppressLint({"RestrictedApi"})
    private void readParamsFronJson() {
        FileReader fileReader;
        IOException e;
        Throwable th;
        BufferedReader bufferedReader = null;
        int i = getDisplayMetrics(this.mViewGroup.getContext()).widthPixels;
        BufferedReader bufferedReader2;
        try {
            fileReader = new FileReader(this.jsonFilePath + "particle.json");
            try {
                bufferedReader2 = new BufferedReader(fileReader);
                try {
                    StringBuilder stringBuilder = new StringBuilder();
                    while (true) {
                        String readLine = bufferedReader2.readLine();
                        if (readLine != null) {
                            stringBuilder.append(readLine);
                        } else {
                            try {
                                break;
                            } catch (JSONException e2) {
                                Log.e(TAG, "json file error: " + e2.getMessage());
                            }
                        }
                    }
                    JSONObject jSONObject = new JSONObject(stringBuilder.toString());
                    if (jSONObject != null) {
                        initParam(i, jSONObject);
                        initRotation(jSONObject);
                        initAcceleration(jSONObject);
                        initSpeed(jSONObject);
                        initScale(jSONObject);
                        initAlpha(jSONObject);
                        initOpacity(jSONObject);
                        initSize(jSONObject);
                    }
                    if (fileReader != null) {
                        try {
                            fileReader.close();
                        } catch (IOException e3) {
                            bqq.ॱ.ˊ(TAG, e3.toString());
                            return;
                        }
                    }
                    if (bufferedReader2 != null) {
                        bufferedReader2.close();
                    }
                } catch (IOException e4) {
                    e3 = e4;
                    bufferedReader = bufferedReader2;
                    try {
                        Log.e(TAG, "json file error: " + e3.getMessage());
                        if (fileReader != null) {
                            try {
                                fileReader.close();
                            } catch (IOException e32) {
                                bqq.ॱ.ˊ(TAG, e32.toString());
                                return;
                            }
                        }
                        if (bufferedReader == null) {
                            bufferedReader.close();
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        bufferedReader2 = bufferedReader;
                        if (fileReader != null) {
                            try {
                                fileReader.close();
                            } catch (IOException e5) {
                                bqq.ॱ.ˊ(TAG, e5.toString());
                                throw th;
                            }
                        }
                        if (bufferedReader2 != null) {
                            bufferedReader2.close();
                        }
                        throw th;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    if (fileReader != null) {
                        fileReader.close();
                    }
                    if (bufferedReader2 != null) {
                        bufferedReader2.close();
                    }
                    throw th;
                }
            } catch (IOException e6) {
                e32 = e6;
                Log.e(TAG, "json file error: " + e32.getMessage());
                if (fileReader != null) {
                    fileReader.close();
                }
                if (bufferedReader == null) {
                    bufferedReader.close();
                }
            } catch (Throwable th4) {
                th = th4;
                bufferedReader2 = null;
                if (fileReader != null) {
                    fileReader.close();
                }
                if (bufferedReader2 != null) {
                    bufferedReader2.close();
                }
                throw th;
            }
        } catch (IOException e7) {
            e32 = e7;
            fileReader = null;
            Log.e(TAG, "json file error: " + e32.getMessage());
            if (fileReader != null) {
                fileReader.close();
            }
            if (bufferedReader == null) {
                bufferedReader.close();
            }
        } catch (Throwable th5) {
            th = th5;
            fileReader = null;
            bufferedReader2 = null;
            if (fileReader != null) {
                fileReader.close();
            }
            if (bufferedReader2 != null) {
                bufferedReader2.close();
            }
            throw th;
        }
    }

    private void initParam(int i, JSONObject jSONObject) throws JSONException {
        this.param.maxParticles = jSONObject.getInt(PARAM_MAXPATICLES);
        this.param.timeToLive = jSONObject.getLong(PARAM_TIMETOLIVE);
        this.param.particlesPerSecond = jSONObject.getInt(PARAM_PARTICLESPERSECOND);
        this.param.fps = jSONObject.getInt(PARAM_FPS);
        JSONArray jSONArray = jSONObject.getJSONArray(PARAM_BITMAPS);
        if (jSONArray != null) {
            int length = jSONArray.length();
            this.param.particle = new Drawable[length];
            for (int i2 = 0; i2 < length; i2++) {
                JSONObject jSONObject2 = jSONArray.getJSONObject(i2);
                if (jSONObject2 != null) {
                    this.param.particle[i2] = Drawable.createFromPath(this.jsonFilePath + jSONObject2.getString(PARAM_BITMAPNAME));
                }
            }
        }
        int[] iArr = new int[]{0, -50, i, 0};
        this.param.rect = new Rect(iArr[0], iArr[1], iArr[2], iArr[3]);
    }

    private void initRotation(JSONObject jSONObject) throws JSONException {
        JSONObject jSONObject2 = jSONObject.getJSONObject(ROTATION);
        if (jSONObject2 != null) {
            this.rotation.rotationSpeed = (float) jSONObject2.getDouble(ROTATION_SPEED);
            this.rotation.minAngle = jSONObject2.getInt("minAngle");
            this.rotation.maxAngle = jSONObject2.getInt("maxAngle");
        }
    }

    private void initSize(JSONObject jSONObject) throws JSONException {
        JSONArray jSONArray = jSONObject.getJSONArray(SIZEOVERLIFE);
        if (jSONArray != null) {
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject2 = jSONArray.getJSONObject(i);
                if (jSONObject2 != null) {
                    SizeOverLife sizeOverLife = new SizeOverLife();
                    sizeOverLife.fromValue = jSONObject2.getInt(OPACITYOVERLIFE_FROMVALUE);
                    sizeOverLife.toValue = jSONObject2.getInt(OPACITYOVERLIFE_TOVALUE);
                    sizeOverLife.startMilis = jSONObject2.getLong(OPACITYOVERLIFE_STARTMILIS);
                    sizeOverLife.endMilis = jSONObject2.getLong(OPACITYOVERLIFE_ENDMILIS);
                    this.sizel.add(sizeOverLife);
                    Log.d(TAG, sizeOverLife.toString());
                }
            }
        }
    }

    private void initOpacity(JSONObject jSONObject) throws JSONException {
        JSONArray jSONArray = jSONObject.getJSONArray(OPACITYOVERLIFE);
        if (jSONArray != null) {
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject2 = jSONArray.getJSONObject(i);
                if (jSONObject2 != null) {
                    OpacityOverLife opacityOverLife = new OpacityOverLife();
                    opacityOverLife.fromValue = jSONObject2.getInt(OPACITYOVERLIFE_FROMVALUE);
                    opacityOverLife.toValue = jSONObject2.getInt(OPACITYOVERLIFE_TOVALUE);
                    opacityOverLife.startMilis = jSONObject2.getLong(OPACITYOVERLIFE_STARTMILIS);
                    opacityOverLife.endMilis = jSONObject2.getLong(OPACITYOVERLIFE_ENDMILIS);
                    this.opacityl.add(opacityOverLife);
                    Log.d(TAG, opacityOverLife.toString());
                }
            }
        }
    }

    private void initAlpha(JSONObject jSONObject) throws JSONException {
        JSONArray jSONArray = jSONObject.getJSONArray(ALPHARANGE);
        if (jSONArray != null) {
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject2 = jSONArray.getJSONObject(i);
                if (jSONObject2 != null) {
                    AlphaRange alphaRange = new AlphaRange();
                    alphaRange.minAlpha = jSONObject2.getInt(ALPHARANGE_MINALPHA);
                    alphaRange.maxAlpha = jSONObject2.getInt(ALPHARANGE_MAXALPHA);
                    this.alphal.add(alphaRange);
                    Log.d(TAG, alphaRange.toString());
                }
            }
        }
    }

    private void initScale(JSONObject jSONObject) throws JSONException {
        JSONArray jSONArray = jSONObject.getJSONArray(SCALERANGE);
        if (jSONArray != null) {
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject2 = jSONArray.getJSONObject(i);
                if (jSONObject2 != null) {
                    ScaleRange scaleRange = new ScaleRange();
                    scaleRange.minScale = (float) jSONObject2.getDouble(SCALERANGE_MINSCALE);
                    scaleRange.maxScale = (float) jSONObject2.getDouble(SCALERANGE_MAXSCALE);
                    this.scalel.add(scaleRange);
                    Log.d(TAG, scaleRange.toString());
                }
            }
        }
    }

    private void initSpeed(JSONObject jSONObject) throws JSONException {
        JSONArray jSONArray = jSONObject.getJSONArray(SPEEDRANGE);
        if (jSONArray != null) {
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject2 = jSONArray.getJSONObject(i);
                if (jSONObject2 != null) {
                    SpeedRange speedRange = new SpeedRange();
                    speedRange.speedMin = (float) jSONObject2.getDouble(SPEEDRANGE_SPEEDMIN);
                    speedRange.speedMax = (float) jSONObject2.getDouble(SPEEDRANGE_SPEEDMAX);
                    speedRange.minAngle = jSONObject2.getInt("minAngle");
                    speedRange.maxAngle = jSONObject2.getInt("maxAngle");
                    this.speedl.add(speedRange);
                    Log.d(TAG, speedRange.toString());
                }
            }
        }
    }

    private void initAcceleration(JSONObject jSONObject) throws JSONException {
        JSONArray jSONArray = jSONObject.getJSONArray(ACCELERATION);
        if (jSONArray != null) {
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject2 = jSONArray.getJSONObject(i);
                if (jSONObject2 != null) {
                    Acceleration acceleration = new Acceleration();
                    acceleration.acceleration = (float) jSONObject2.getDouble(ACCELERATION_ACCELERATION);
                    acceleration.minAngle = jSONObject2.getInt("minAngle");
                    acceleration.maxAngle = jSONObject2.getInt("maxAngle");
                    this.al.add(acceleration);
                    Log.d(TAG, acceleration.toString());
                }
            }
        }
    }

    private static DisplayMetrics getDisplayMetrics(Context context) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        if (context != null) {
            ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
        }
        return displayMetrics;
    }
}
